package com.ayoka.parenting.ui.meditation.index;

import com.ayoka.parenting.R;
import com.ayoka.parenting.bean.MeditationIndexDataBean;
import com.ayoka.parenting.interf.SimpleRequestCallback;
import com.ayoka.parenting.mvp.BasePresenterImpl;
import com.jincp.common.utils.UIUtils;

/**
 * @ProjectName: MVPPlugin.
 * @ClassName: MeditationIndexPresenter.
 * @Description: .
 * @Author: jincp.
 * @CreateDate: 2019/10/10 18:17.
 */
public class MeditationIndexPresenter extends BasePresenterImpl<MeditationIndexContract.View> implements MeditationIndexContract.Presenter {

    private MeditationIndexModel model;

    public MeditationIndexPresenter() {
        model = new MeditationIndexModel();
    }

    public void getMeditationIndexData() {
        mView.get().showWaitDialog(UIUtils.getString(R.string.loading));
        model.getMeditationIndexData(this, new SimpleRequestCallback<MeditationIndexDataBean>() {
            @Override
            public void onSuccess(MeditationIndexDataBean data) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().configMeditationIndexData(data);
            }

            @Override
            public void onFailure(int errCode, String errMsg) {
                if (!isAttached()) return;
                mView.get().hideWaitDialog();
                mView.get().configMeditationIndexData(null);
            }
        });
    }
}
